<html>
<script>

var time1 = 0;
var time2 = 0;

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function log(message)
{
    document.getElementById("log").innerText += message + "\n";
}

function firstScript()
{
    log("Running first script.");
    time1 = new Date().getTime();
}

function secondScript()
{
    log("Running second script.");
    time2 = new Date().getTime();
}

function test()
{
    // Second script is sent after a 1 second delay. If time delta
    // between both scripts running is really small, that means they
    // ran back-to-back instead of the first script running before
    // the second script was loaded.
    if (time2 - time1 < 50)
        log("FAIL: Gap between script runs unexpectedly small.");
    else
        log("PASS: First script ran before second script was loaded.");

    if (window.testRunner)
        testRunner.notifyDone();
}
</script>
<body onload="test()">
<pre id="log"></pre>
<iframe id="frame" src="resources/charset-sniffer-end-sniffing.php"></iframe>
<p>This test is for a bug where the charset sniffer would not stop looking
for charset if the body contains no tags. Charset sniffer is supposed to stop
looking for charset after 1024 bytes.</p>
</body>
</html>
